package com.ekuaitu.kuaitu.ble;

import com.inuker.bluetooth.library.connect.response.BleNotifyResponse;

import java.util.UUID;

/**
 * Created by user1 on 2017/4/10.
 */

public class BleNotify {
    private static volatile BleNotify instance = null;
    public static int fromActivity;
    private BlueNotifyCallBack blueNotifyCallBack;

    public void setFromActivity(int fromActivity) {
        BleNotify.fromActivity = fromActivity;
    }

    public static BleNotify getInstance() {
        if (instance == null) {
            instance = new BleNotify();
        }
        return instance;
    }

    public void setBleNotifyCallBack(BlueNotifyCallBack blueNotifyCallBack) {
        this.blueNotifyCallBack = blueNotifyCallBack;
    }

    public BleNotifyResponse getBleNotifyResponse() {
        return bleNotifyResponse;
    }

    private BleNotifyResponse bleNotifyResponse = new BleNotifyResponse() {
        @Override
        public void onNotify(UUID service, UUID character, byte[] value) {
            if (blueNotifyCallBack != null) {
                blueNotifyCallBack.onNotify(service, character, value);
            }
//            if (fromActivity == 1) {
//                EventBus.getDefault().post(new BleNotifyScanEvent(value));
//            } else if (fromActivity == 2) {
//                EventBus.getDefault().post(new BleNotifyInputEvent(value));
//            } else if (fromActivity == 3) {
//                EventBus.getDefault().post(new BleNotifyInuseEvent(value));
//            } else if (fromActivity == 4) {
//                EventBus.getDefault().post(new BleNotifyRepairEvent(value));
//            }
        }

        @Override
        public void onResponse(int code) {

        }
    };

    public interface BlueNotifyCallBack {
        void onNotify(UUID service, UUID character, byte[] value);
    }
}
